/**
 * 
 */
package com.johnburrin.mortgage.estimator;

/**
 * @author John
 *
 */
public class financial {
	/**
	 * The pmt (payment)function returns the monthly payment amount for a loan based on an
	 * interest rate and a constant payment schedule. This is based on the excel pmt function
	 * loanlength is assumed to be in years
	 * @param amount
	 * @param interestPerMonth
	 * @param loanLength in years 
	 * @return
	 * 
	 * 
	 */
	public static double pmt(double amount, double interestPerMonth, double loanLength){
		double iPM = interestPerMonth /100;
		
		double pmt = amount /((1-Math.pow(1/(1+((iPM)/12)),(loanLength*12)))/((iPM)/12));
		return pmt;
				
	}
}
